function electrical_angle = calculateElectricalAngle(encoder_value)
    % Define the lookup table
    encoder_values = [26, 399, 786, 1199, 1550, 1949, 2404, 2748, 3101, 3534, ...
        3919, 4265, 4718, 5127, 5477, 5872, 6264, 6653, 7047, 7460, 7863, ...
        8236, 8599, 8992, 9419, 9775, 10178, 10619, 10946, 11307, 11763, ...
        12147, 12487, 12928, 13324, 13671, 14074, 14463, 14841, 15228, ...
        15622, 16017];
    
    % Add the first value at the end to complete the 360-degree cycle
    encoder_values = [encoder_values, encoder_values(1)];
    
    % Find the index of the closest encoder value
    [~, index] = min(abs(encoder_values - encoder_value));
    
    % Calculate the electrical angle (each step is 60 electrical degrees)
    electrical_angle = (index - 1) * 60;
    
    % If the encoder value is between two points, interpolate
    if index > 1 && index < length(encoder_values)
        prev_value = encoder_values(index-1);
        next_value = encoder_values(index);
        
        % Linear interpolation
        if encoder_value > prev_value && encoder_value < next_value
            ratio = (encoder_value - prev_value) / (next_value - prev_value);
            electrical_angle = (index - 1) * 60 + ratio * 60;
        end
    end
    
    % Convert to 0-360 degree range
    electrical_angle = mod(electrical_angle, 360);
end 